 
.386p
.model FLAT

.data

.code
mymemalloc_ proc
 push    esi
 push    edi
 push    ecx
 push    ds
 mov     ds,dx
 or      eax,eax
 je      memalloc_pnt1
 add     eax,0000000B
 jb      memalloc_pnt1
 and     al,0F8h
 mov     edx,00000010
 sub     eax,edx
 cmc     
 sbb     ecx,ecx
 and     eax,ecx
 add     eax,edx
 cmp     eax,+14h[ebx]    
 ja      memalloc_pnt1
 mov     esi,+0Ch[ebx]
 mov     edi,+10h[ebx]
 cmp     eax,edi
 ja      memalloc_pnt2
 mov     esi,+28h[ebx]  
 sub     edi,edi
memalloc_pnt2:
 mov     edx,[esi]    
 cmp     eax,edx
 jbe     memalloc_pnt3
 sub     edi,edx
 cmc     
 sbb     ecx,ecx
 and     edi,ecx
 add     edi,edx
 lea     edx,+20h[ebx]
 mov     esi,+8h[esi]
 cmp     esi,edx
 jne     memalloc_pnt2
 mov     +14h[ebx],edi  
memalloc_pnt1:
 sub     eax,eax
 jmp     memalloc_finish
memalloc_pnt3:
 sub     edx,eax
 mov     +10h[ebx],edi      
 inc     dword ptr +18h[ebx] 
 mov     ecx,+8h[esi]       
 cmp     edx,00000010h
 jb      memalloc_pnt4
 mov     edi,esi
 add     edi,eax
 mov     +0Ch[ebx],edi     
 mov     [edi],edx       
 mov     [esi],eax      
 mov     ebx,+4[esi]   
 mov     +4[edi],ebx  
 mov     +8[edi],ecx 
 mov     +8[ebx],edi
 mov     ebx,ecx
 mov     +4[ebx],edi 
 jmp     memalloc_pnt5
memalloc_pnt4:
 dec     dword ptr +1Ch[ebx]       
 mov     eax,esi
 mov     edi,ecx
 mov     esi,+4[esi]             
 mov     +8[esi],edi            
 mov     +4[edi],esi           
 mov     +0Ch[ebx],esi         
 mov     esi,eax
memalloc_pnt5:
 or      dword ptr [esi],00000001h
 mov     eax,esi
 add     eax,00000004h
memalloc_finish:
 pop     ds
 pop     ecx
 pop     edi
 pop     esi
 ret     
mymemalloc_ endp
end
